//
//  ZH_MinePayTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/24.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MinePayTableViewCell.h"
@interface ZH_MinePayTableViewCell()
@property (nonatomic,weak)UILabel *leftLabel;
@property (nonatomic,weak)UIImageView *rightImage;
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UIView *bgView;
@property (nonatomic,weak)UIImageView *image;
@property (nonatomic,weak)UIButton *button;
@property (nonatomic,weak)UIImageView *bottomImage;
@property (nonatomic,weak)UILabel *bottomLabel;

@end
@implementation ZH_MinePayTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MinePayTableViewCell";
    ZH_MinePayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MinePayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(18));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
    }];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.leftLabel);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
        make.width.mas_equalTo(FITSCALE(9));
        make.height.mas_equalTo(FITSCALE(14));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftLabel.mas_bottom).offset(FITSCALE(17));
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(FITSCALE(1));
    }];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(FITSCALE(281));
    }];
    [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView).offset(FITSCALE(19));
        make.centerX.equalTo(self.contentView);
        make.width.mas_equalTo(FITSCALE(241));
        make.height.mas_equalTo(FITSCALE(241));
    }];
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView.mas_bottom).offset(FITSCALE(48));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
        make.height.mas_equalTo(FITSCALE(46));
    }];
    [self.bottomImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.button.mas_bottom).offset(FITSCALE(30));
        make.left.equalTo(self.contentView).offset(FITSCALE(85));
    }];
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bottomImage);
        make.left.equalTo(self.bottomImage.mas_right).offset(FITSCALE(4));
    }];

}
#pragma mark - getter,setter
- (UILabel *)leftLabel{
    if (!_leftLabel) {
        UILabel *label = [UILabel createLabelWithText:@"收款码:" font:kFontSize_30];
        [self.contentView addSubview:_leftLabel = label];
    }
    return _leftLabel;
}
- (UIImageView *)rightImage{
    if (!_rightImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_mygetmore1"];
        [self.contentView addSubview:_rightImage = image];
    }
    return _rightImage;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_lineView = view];
    }
    return _lineView;
}
- (UIView *)bgView{
    if (!_bgView) {
        UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
        [self.contentView addSubview:_bgView = view];
    }
    return _bgView;
}
- (UIImageView *)image{
    if (!_image) {
        UIImageView *image = [UIImageView createImageViewWithName:@""];
        image.backgroundColor = kFontColorRed;
        [self.contentView addSubview:_image = image];
    }
    return _image;
}
- (UIButton *)button{
    if (!_button) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"确认" target:self action:nil];
        button.backgroundColor = [UIColor colorWithHexString:@"#00C9AE"] ;
        [button setTitleColor:kFontColorWhite forState:UIControlStateNormal];
        button.layer.cornerRadius = FITSCALE(22);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        [self.contentView addSubview:_button = button];
    }
    return _button;
}
- (UIImageView *)bottomImage{
    if (!_bottomImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_ts"];
        [self.contentView addSubview:_bottomImage = image];
    }
    return _bottomImage;
}
- (UILabel *)bottomLabel{
    if (!_bottomLabel) {
        UILabel *label = [UILabel createLabelWithText:@"温馨提示: 如果需要修改, 请联系客服564648" font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#999999"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_22,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FE4949"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"564648"]];
        label.attributedText = attr;
        [self.contentView addSubview:_bottomLabel = label];
    }
    return _bottomLabel;
}
@end
